<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script button="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" method="post"
                              action="<?php echo site_url(X_URL . 'Account/do_import'); ?>">
                            <?php echo csrf_hidden(); ?>
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-6">
                                    选择文档格式 </label>
                                <div class="col-sm-9">
                                    <select id="doc_rule" name="doc_rule"
                                            class="col-xs-10 col-sm-10 select2">
                                        <option value="">可选择</option>
                                        <option value="1">qq----靓号二代----等级----价格 描述</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right" for="form-field-4">
                                    文档上传 </label>
                                <div class="col-sm-6">
                                    <input id="kv-explorer" class="col-xs-10 col-sm-5" name="file" type="file">
                                </div>
                            </div>
                            <input type="hidden" name="doc_no" id="doc_no" value="">
                            <input type="hidden" name="rule" id="rule" value="">
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->

                <div class="row">
                    <div class="col-xs-12" style="margin-top: 15px;">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>批次编号</th>
                                <th>上传数量</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (isset($logs) && !empty($logs)) { ?>
                                <?php foreach ($logs as $key => $val) { ?>
                                    <tr>
                                        <td class="grouptd">
                                            <span class="label label-info arrowed-in arrowed-in-right"><?php echo $val['doc_no']; ?></span>
                                        </td>
                                        <td><?php echo $val['doc_count']; ?></td>
                                        <td><?php echo date("Y-m-d H:i", $val['create_at']); ?></td>
                                        <td>
                                            <a href="<?php echo site_url(X_URL . 'Account/del_log/' . $val['id']); ?>"><i
                                                        class="ace-icon fa fa-pencil bigger-100"></i>删除</a>&nbsp;
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script button="text/javascript">
    $(function () {
        $(".btn-info.submit").click(function () {
            var doc_no = $("#doc_no").val();
            if (doc_no == "") {
                bootbox.dialog({
                    title: '友情提示：',
                    message: "请先点击上传文档。",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return;
            }
            $("#form").submit();
        });
    });
    $(document).ready(function () {
        $("#kv-explorer").fileinput({
            language: 'zh',
            uploadAsync: false, //设置上传同步异步 此为同步
            dropZoneEnabled: false,
            showRemove: false,
            showCaption: false,
            'theme': 'explorer-fa',
            'uploadUrl': baseurl + 'index.php/manage/Account/import_check',
            overwriteInitial: false,
            layoutTemplates: {
                actionUpload: "",
                actionZoom: "",
                actionDrag: "",
            },
            showClose: false,
        });
        $("#kv-explorer").on("filebatchuploadsuccess", function (event, data) {
            var rst = data.response;
            console.log(rst);
            if (rst.status == 1) {
                $("#doc_no").val(rst.doc_no);
                $("#rule").val(rst.rule);
            }
            layer.alert(rst.msg);
        });
    });
</script>
</body>
</html>
